package com.scut.online_black_market.controller;

import com.scut.online_black_market.dto.SuccessResponse;
import com.scut.online_black_market.service.MailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * create by yellowBroke on 2020/11/2 11:39
 */

@RestController
@RequestMapping(value = "/mail")
@Api(value = "邮件接口",tags = "邮箱接口")
public class MailController {

    @Resource
    private MailService mailService;

    @ApiOperation("发送邮件验证码")
    @RequestMapping(value = "/validateCode/{to}",method = RequestMethod.POST)
    public ResponseEntity<SuccessResponse> getMailValidateCode(@PathVariable String to){
        mailService.sendMail(to);
        return ResponseEntity.ok(new SuccessResponse(true, "验证码已发送到" + to));
    }
}
